<template>
  <div class="notice">
    <h2 class="title">{{title?title:'公告'}}</h2>
    <div class="content">
      <ul>
        <li v-for="notice in list" :class="{'is-read':notice.isRead}">
          <a :href="notice.url" target="_blank">
          <span class="notice-title">{{notice.title || notice.content}}</span>
          <span class="notice-date">{{notice.dbUpdateTime | date('yyyy年MM月dd日')}}</span>
          <div v-if="notice.content||notice.url" class="notice-content">{{notice.content||'点击标题查看详情'}}</div>
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Notice',
  props: ['list','title']
};
</script>

<style lang="less">
.notice {
  margin-top: 30px;
  .title {
    font-size: 20px;
    font-weight: normal;
    color: #666;
    border-bottom: solid 1px #e7e7e7;
    padding-bottom: 15px;
  }
  .content li {
    position: relative;
    height: 32px;
    margin: 4px 0;
    border-radius: 5px;
    color: #343434;
    line-height: 32px;
    cursor: pointer;
    transition: .25s;
    &>a{
      display: block;
    }
    &.is-read{
      color: #999;
    }
    &:hover {
      color: #2e9057;
      background: #f8f8f8;
      .notice-content {
        transform:none;
        visibility: visible;
        opacity: 1;
      }
    }
  }
  .notice-title {
    padding-left: 20px;
    font-size: 14px;
    &:before {
      content: '·';
      margin-right: 4px;
      font-weight: 700;
    }
  }
  .notice-date {
    float: right;
    font-size: 12px;
    color: #999;
    margin-right: 40px;
  }
  .notice-content {
    box-sizing: border-box;
    position: absolute;
    top: 100%;
    max-width: 360px;
    left: 16px;
    margin-top: 10px;
    padding: .5em 1em;
    border-radius: 5px;
    background: #2e9057;
    color: #fff;
    text-align: justify;
    text-justify: inter-ideograph;
    line-height: 1.75em;
    //box-shadow: 0 0 5px rgba(0, 0, 0, 0.25);
    transform: translateY(-5px);
    transition: .25s;
    opacity: 0;
    visibility: hidden;
    z-index: 50;
    cursor: default;
    pointer-events: none;
    &:before{
      content: ' ';
      display: block;
      position: absolute;
      bottom: 100%;
      left: 24px;
      border: 6px solid transparent;
      border-bottom-color: #2e9057;
    }
  }
  a{
    color: #666;
    &:hover{
      color: #2e9057;
    }
  }
}
</style>